package com.yonyou.rabbitmq.receiver;

import com.rabbitmq.client.Channel;
import com.yonyou.rabbitmq.common.MessageConstants;
import com.yonyou.rabbitmq.service.BaseConsumerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DeadLetterReceiver extends BaseConsumerService {

    @RabbitListener(containerFactory = MessageConstants.GF_CONTAINER_FACTORY,queues = MessageConstants.DLQ_QUEUE)
    @RabbitHandler
    public void gfMessage(Channel channel, Message message) throws Exception {
        super.process(channel,message);
    }

    @RabbitListener(containerFactory = MessageConstants.ZW_CONTAINER_FACTORY,queues = MessageConstants.DLQ_QUEUE)
    @RabbitHandler
    public void zwMessage(Channel channel, Message message) throws Exception {
        super.process(channel,message);
    }

    @Override
    public void doBusiness(Message message, String tenantId) {
        System.out.println(tenantId + "站点实际业务处理");
        log.info("死信队列，消费消息：{}",message);
    }
}
